﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BOMS.Model;
using System.Drawing;
using System.Data;
using BOMS.DAL;

namespace BOMS.WebUI.Web
{
    public partial class Message : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                EquipStatusCount();
            }
            
        }

        void EquipStatusCount()
        {
            DataSet ds = new DataSet();
            ds = RealDate.getWinceInfoOfLan();

            DataTable dt = ds.Tables[0];
            int nOnline = 0;
            int nOffLine = 0;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DateTime LastTime = (DateTime)dt.Rows[i]["LatestTime"];
                TimeSpan ts = new TimeSpan(0, 3, 0);//3分钟；
                if (DateTime.Now > LastTime.Add(ts))//已超时
                {
                    nOffLine++;
                }
                else
                {
                    nOnline++;
                }
            }
            //掉线
            lblOfflineCount.Text = nOffLine.ToString();
            //在线
            lblOnLineCount.Text = nOnline.ToString();

            int nPowerdown = RealDate.getPowerDownEquipCount();
            //停电的主机数量
            lblPowerDown.Text = nPowerdown.ToString();

            int nWarning = RealDate.getWarningEquipCount();
            //报警的主机数量
            lblWarning.Text = nWarning.ToString();

            //全网主机数量
            lblAllEquipCount.Text = (nOffLine + nOnline).ToString();

        }
       
    }

}